home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14439 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  35 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!smryan
  3. From: smryan@netcom.com (@#$%!?!)
  4. Subject: Re: Can anyone solve this problem?
  5. Message-ID: <smryanDpuDDr.CKC@netcom.com>
  6. Organization: The Programmer formerly known as S M Ryan
  7. X-Newsreader: TIN [version 1.2 PL1]
  8. References: <4kosek$12q@usenet.kornet.nm.kr>
  9. Date: Sun, 14 Apr 1996 07:41:51 GMT
  10. Sender: smryan@netcom13.netcom.com
  11.  
  12. : i can't understand what this problem exactly mean because i'm
  13. : not so friendly in english.
  14.  
  15. :  problem is: "write a function rightrot(x,n) that returns the
  16. :               value of the integer x rotated to the right by
  17. :               n bit positions."
  18.  
  19. When you right-shift a value, the rightmost bits are discarded. When
  20. you right rotate, the bits are moved around to leftmost position. For
  21. an eight-bit value
  22.     abcdefgh
  23. right shifting three bits gives you
  24.     000abcde or 111abcde
  25. right rotating gives you
  26.     fghabcde
  27.  
  28. Draw the picture, look at it, and the code should become obvious.
  29.  
  30. -- 
  31. The Queen, amused, in quiet power,         | smryan@netcom.com  PO Box 1563
  32. will draw the son to darkenned bower.      |          Cupertino, California
  33. Her face is fair, her fragrance rare,      | (xxx)xxx-xxxx            95015
  34. with woven webs for wayward flower.        |         I don't use no smileys
  35.